/** 
  Copyright (c) 2008, 2009 Claudio Imbrenda
  This program is released under the terms of the
  GNU GPL version 3 or later.
*/
package macchina;

import java.io.*;
import macchina.telescriventi.*;

/**
 *
 * @author the_nihilant
 */
public class Assembler {
  
  private Assembler(){}
  
  public static void main(String[]argv)
              throws FileNotFoundException,SyntaxErrorException,IOException{
    try{
      Macchina m = new Macchina();
      File inf = new File(argv[1]);
      File outf= new File(argv[2]);
      ASCIIFileTelescrivente ft;
      FileOutputStream fos;
    
      Assemblatore as=new Assemblatore(inf, m);
    
      if(argv[0].equalsIgnoreCase("-n"))
        as.assemble(ft=new ASCIIFileTelescrivente(outf));
      else if(argv[0].equalsIgnoreCase("-d"))
        as.assemble(fos=new FileOutputStream(outf));
      else pusage();
      System.out.println(as.getLog());
    }catch(IndexOutOfBoundsException e){pusage();}
   
    //ft.c();
  }
  
  private static void pusage(){
    System.out.println("Usage:\n Assembler -n in out\t Nastro\n"+
            " Assembler -d in out\t Dump\n");
  }

}
